package com.thememaker.util;

import com.thememake.ui.Toast;
import com.thememake.util.FileUtils;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class VersionControlUtils {

    public final static String VERSIONNAME = "1.0.5";
    public final static int VERSIONCODE = 105;
    public final static boolean DEBUG = true;

    public static void checkVersion(){
        Path libsPath = Paths.get(FileUtils.getUserDirResPath(),"libs");
        if (Files.exists(libsPath)){
            //开始检测是否包含 锁屏jar包 不是当前版本就删除
            try {
                FileUtils.iteratorDirToStream(libsPath.toFile(),true)
                        .filter(path -> path.getFileName().toString().contains("lockscreenMaker") && !path.getFileName().toString().contains(VERSIONNAME))
                        .forEach(path -> {
                            try {
                                System.err.println("删除 >>>> " + path.toString());
                                Files.delete(path);
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        });
            } catch (IOException e) {
                e.printStackTrace();
            }
            ;
        }
    }
}
